﻿using System;
using System.Collections.Generic;
using Assist;
using Autodesk.Revit.DB;
using YJKArch.Utils;

namespace YJKArch.DormantWindow
{
	public class DormantPlotter
	{
		public List<CurveInfo> Curves
		{
			get
			{
				return this.m_Curves;
			}
		}

		public List<TextNoteInfo> Texts
		{
			get
			{
				return this.m_Texts;
			}
		}

		public List<FillRegion> FillRegions
		{
			get
			{
				return this.m_FillRegions;
			}
		}

		private XYZ TransformPoint(XYZ pt, Transform transform)
		{
			return Geometry.TransformPoint(pt, transform);
		}

		private XYZ NewPoint(double x, double y, double z, Transform transform)
		{
			XYZ pt = new XYZ(x, y, z);
			return this.TransformPoint(pt, transform);
		}

		public void Draw(Transform transform, double dormantWidth, double maxRidgeHeight, double wallHeight, double roofThickness, double wallThickness, double windowWidth, double windowHeight, double windowSymbolElevation, double windowBottomElevation, List<XYZ> windowProfile, double slopeAngle, double eavesOffset, List<List<EdgeInfo>> windowLoops, List<bool> isGlass, bool isTransparent, bool onlyShowWindow)
		{
			this.m_CurrentTransform = transform;
			this.m_IsTransparent = isTransparent;
			this.m_OnlyShowWindow = onlyShowWindow;
			double num = dormantWidth / 2.0;
			double num2 = wallHeight / Math.Tan(slopeAngle);
			double y = (maxRidgeHeight + wallHeight) * num2 / wallHeight;
			XYZ ptFrontLeftBottom = this.NewPoint(-num, 0.0, 0.0, transform);
			XYZ ptFrontRightBottom = this.NewPoint(num, 0.0, 0.0, transform);
			XYZ xyz = this.NewPoint(-num, 0.0, wallHeight, transform);
			XYZ xyz2 = this.NewPoint(0.0, 0.0, wallHeight + maxRidgeHeight, transform);
			XYZ xyz3 = this.NewPoint(num, 0.0, wallHeight, transform);
			XYZ xyz4 = this.NewPoint(-num, num2, wallHeight, transform);
			XYZ xyz5 = this.NewPoint(0.0, y, wallHeight + maxRidgeHeight, transform);
			XYZ xyz6 = this.NewPoint(num, num2, wallHeight, transform);
			double num3 = windowWidth / 2.0;
			XYZ xyz7 = this.NewPoint(-num3, 0.0, windowBottomElevation, transform);
			XYZ xyz8 = this.NewPoint(num3, 0.0, windowBottomElevation, transform);
			XYZ xyz9 = this.NewPoint(-num3, 0.0, windowBottomElevation + windowHeight, transform);
			XYZ xyz10 = this.NewPoint(num3, 0.0, windowBottomElevation + windowHeight, transform);
			XYZ ptBackLeftBottom = this.NewPoint(-num3, wallThickness, windowBottomElevation, transform);
			XYZ ptBackRightBottom = this.NewPoint(num3, wallThickness, windowBottomElevation, transform);
			XYZ ptBackLeftTop = this.NewPoint(-num3, wallThickness, windowBottomElevation + windowHeight, transform);
			XYZ ptBackRightTop = this.NewPoint(num3, wallThickness, windowBottomElevation + windowHeight, transform);
			double num4 = windowBottomElevation - windowSymbolElevation;
			if (!this.m_OnlyShowWindow)
			{
				Transform transform2 = RevitVersionFuncs.CreateTranslation(new XYZ(0.0, 0.0, num4));
				Transform transform3 = transform.Multiply(transform2);
				List<XYZ> list = new List<XYZ>();
				foreach (XYZ point in windowProfile)
				{
					list.Add(Geometry.TransformPoint(point, transform3));
				}
				this.DrawWalls(ptFrontLeftBottom, ptFrontRightBottom, xyz, xyz2, xyz3, xyz4, xyz5, xyz6, xyz7, xyz8, xyz9, xyz10, transform, dormantWidth, maxRidgeHeight, wallHeight, wallThickness, list, windowWidth, windowHeight, windowBottomElevation, PenColor.PC_LightGray);
				this.DrawRoof(roofThickness, transform, xyz, xyz2, xyz3, xyz4, xyz5, xyz6, eavesOffset, PenColor.PC_LightBlue);
				this.DrawOpening(xyz7, xyz8, xyz9, xyz10, ptBackLeftBottom, ptBackRightBottom, ptBackLeftTop, ptBackRightTop, list, wallThickness, transform, PenColor.PC_LightGray);
			}
			this.DrawWindow(windowLoops, isGlass, wallThickness, num4, transform);
			this.m_FillRegions.Sort(new FillRegionZComparer());
		}

		private void AddFillRegion(FillRegion region)
		{
			if (!this.m_IsTransparent && Geometry.GreaterThan(region.Normal().Z, 0.0))
			{
				return;
			}
			this.m_FillRegions.Add(region);
		}

		private int ReverseEdgeIndex(int count, int index)
		{
			int num = count - 2 - index;
			if (num < 0)
			{
				num += count;
			}
			return num;
		}

		private void DrawWalls(XYZ ptFrontLeftBottom, XYZ ptFrontRightBottom, XYZ ptFrontLeftTop, XYZ ptFrontMiddleTop, XYZ ptFrontRightTop, XYZ ptBackLeftTop, XYZ ptBackMiddleTop, XYZ ptBackRightTop, XYZ ptOpeningFrontLeftBottom, XYZ ptOpeningFrontRightBottom, XYZ ptOpeningFrontLeftTop, XYZ ptOpeningFrontRightTop, Transform transform, double dormantWidth, double maxRidgeHeight, double wallHeight, double wallThickness, List<XYZ> windowProfile, double windowWidth, double windowHeight, double windowElevation, PenColor profileColor)
		{
			double num = maxRidgeHeight * 2.0 * wallThickness / dormantWidth;
			XYZ xyz = Geometry.TransformPoint(XYZ.BasisZ, transform) * num;
			double num2 = ptFrontMiddleTop.DistanceTo(ptBackMiddleTop);
			double num3 = num * num2 / (maxRidgeHeight + wallHeight + num);
			XYZ xyz2 = Geometry.TransformPoint(XYZ.BasisY, transform) * num3;
			XYZ xyz3 = Geometry.TransformPoint(XYZ.BasisY, transform) * wallThickness;
			XYZ xyz4 = Geometry.TransformPoint(XYZ.BasisX, transform) * wallThickness;
			XYZ xyz5 = -xyz4;
			if (windowProfile.Count == 0)
			{
				List<XYZ> list = new List<XYZ>();
				list.Add(ptOpeningFrontLeftTop);
				list.Add(ptOpeningFrontRightTop);
				list.Add(ptOpeningFrontRightBottom);
				List<XYZ> list2 = new List<XYZ>();
				list2.Add(ptOpeningFrontRightBottom);
				list2.Add(ptOpeningFrontLeftBottom);
				list2.Add(ptOpeningFrontLeftTop);
				this.DrawWallFront(ptFrontLeftBottom, ptFrontRightBottom, ptFrontLeftTop, ptFrontMiddleTop, ptFrontRightTop, list, list2, profileColor, true);
				this.OffsetLoop(ref list, xyz3);
				this.OffsetLoop(ref list2, xyz3);
				this.DrawWallFront(ptFrontLeftBottom + xyz3 + xyz4, ptFrontRightBottom + xyz3 + xyz5, ptFrontLeftTop + xyz3 + xyz4 + xyz, ptFrontMiddleTop + xyz3, ptFrontRightTop + xyz3 + xyz5 + xyz, list, list2, profileColor, false);
			}
			else
			{
				List<XYZ> topWindowPath = new List<XYZ>();
				List<XYZ> bottomWindowPath = new List<XYZ>();
				this.SpliteWindowProfile(windowProfile, windowWidth, windowHeight, windowElevation, transform, ref topWindowPath, ref bottomWindowPath);
				this.DrawWallFront(ptFrontLeftBottom, ptFrontRightBottom, ptFrontLeftTop, ptFrontMiddleTop, ptFrontRightTop, topWindowPath, bottomWindowPath, profileColor, true);
				this.OffsetLoop(ref topWindowPath, xyz3);
				this.OffsetLoop(ref bottomWindowPath, xyz3);
				this.DrawWallFront(ptFrontLeftBottom + xyz3 + xyz4, ptFrontRightBottom + xyz3 + xyz5, ptFrontLeftTop + xyz3 + xyz4 + xyz, ptFrontMiddleTop + xyz3, ptFrontRightTop + xyz3 + xyz5 + xyz, topWindowPath, bottomWindowPath, profileColor, false);
			}
			FillRegion region = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontRightBottom,
				ptFrontRightBottom + xyz3,
				ptBackRightTop,
				ptFrontRightTop
			}, profileColor);
			this.AddFillRegion(region);
			FillRegion region2 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontLeftBottom,
				ptFrontLeftTop,
				ptBackLeftTop,
				ptFrontLeftBottom + xyz3
			}, profileColor);
			this.AddFillRegion(region2);
			FillRegion region3 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontRightBottom + xyz3 + xyz5,
				ptFrontRightTop + xyz3 + xyz5 + xyz,
				ptBackRightTop + xyz5 + xyz + xyz2
			}, profileColor);
			this.AddFillRegion(region3);
			FillRegion region4 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontLeftBottom + xyz3 + xyz4,
				ptBackLeftTop + xyz4 + xyz + xyz2,
				ptFrontLeftTop + xyz3 + xyz4 + xyz
			}, profileColor);
			this.AddFillRegion(region4);
			FillRegion region5 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontLeftBottom + xyz3,
				ptBackLeftTop,
				ptBackLeftTop + xyz4 + xyz + xyz2,
				ptFrontLeftBottom + xyz3 + xyz4
			}, profileColor);
			this.AddFillRegion(region5);
			FillRegion region6 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontRightBottom + xyz3,
				ptFrontRightBottom + xyz3 + xyz5,
				ptBackRightTop + xyz5 + xyz + xyz2,
				ptBackRightTop
			}, profileColor);
			this.AddFillRegion(region6);
		}

		private void OffsetLoop(ref List<XYZ> loop, XYZ offset)
		{
			for (int i = 0; i < loop.Count; i++)
			{
				List<XYZ> list = loop;
				int index = i;
				list[index] += offset;
			}
		}

		private void DrawWallFront(XYZ ptFrontLeftBottom, XYZ ptFrontRightBottom, XYZ ptFrontLeftTop, XYZ ptFrontMiddleTop, XYZ ptFrontRightTop, List<XYZ> topWindowPath, List<XYZ> bottomWindowPath, PenColor profileColor, bool isOutside)
		{
			List<XYZ> list = new List<XYZ>();
			list.Add(ptFrontLeftBottom);
			list.Add(ptFrontRightBottom);
			foreach (XYZ item in bottomWindowPath)
			{
				list.Add(item);
			}
			list.Add(ptFrontLeftTop);
			if (!isOutside)
			{
				list.Reverse();
			}
			FillRegion fillRegion = this.CreateFillRegions(list, profileColor);
			if (!isOutside)
			{
				fillRegion.SetEdgeTransparent(this.ReverseEdgeIndex(list.Count, 1));
				fillRegion.SetEdgeTransparent(this.ReverseEdgeIndex(list.Count, 1 + bottomWindowPath.Count));
			}
			else
			{
				fillRegion.SetEdgeTransparent(1);
				fillRegion.SetEdgeTransparent(1 + bottomWindowPath.Count);
			}
			this.AddFillRegion(fillRegion);
			List<XYZ> list2 = new List<XYZ>();
			list2.Add(ptFrontLeftTop);
			foreach (XYZ item2 in topWindowPath)
			{
				list2.Add(item2);
			}
			list2.Add(ptFrontRightBottom);
			list2.Add(ptFrontRightTop);
			list2.Add(ptFrontMiddleTop);
			if (!isOutside)
			{
				list2.Reverse();
			}
			FillRegion fillRegion2 = this.CreateFillRegions(list2, profileColor);
			if (!isOutside)
			{
				fillRegion2.SetEdgeTransparent(this.ReverseEdgeIndex(list2.Count, 0));
				fillRegion2.SetEdgeTransparent(this.ReverseEdgeIndex(list2.Count, topWindowPath.Count));
				fillRegion2.SetEdgeTransparent(this.ReverseEdgeIndex(list2.Count, list2.Count - 2));
				fillRegion2.SetEdgeTransparent(this.ReverseEdgeIndex(list2.Count, list2.Count - 1));
			}
			else
			{
				fillRegion2.SetEdgeTransparent(0);
				fillRegion2.SetEdgeTransparent(topWindowPath.Count);
				fillRegion2.SetEdgeTransparent(list2.Count - 2);
				fillRegion2.SetEdgeTransparent(list2.Count - 1);
			}
			this.AddFillRegion(fillRegion2);
		}

		private void SpliteWindowProfile(List<XYZ> windowProfile, double windowWidth, double windowHeight, double windowElevation, Transform transform, ref List<XYZ> topWindowPath, ref List<XYZ> bottomWindowPath)
		{
			XYZ xyz = new XYZ(-windowWidth / 2.0, 0.0, windowElevation + windowHeight);
			xyz = Geometry.TransformPoint(xyz, transform);
			XYZ xyz2 = new XYZ(windowWidth / 2.0, 0.0, windowElevation);
			xyz2 = Geometry.TransformPoint(xyz2, transform);
			int num = -1;
			int num2 = -1;
			double val = double.MaxValue;
			double val2 = double.MaxValue;
			for (int i = 0; i < windowProfile.Count; i++)
			{
				XYZ xyz3 = windowProfile[i];
				double num3 = xyz3.DistanceTo(xyz);
				if (Geometry.LessThan(num3, val))
				{
					val = num3;
					num = i;
				}
				double num4 = xyz3.DistanceTo(xyz2);
				if (Geometry.LessThan(num4, val2))
				{
					val2 = num4;
					num2 = i;
				}
			}
			for (int i = num; i < windowProfile.Count; i++)
			{
				bottomWindowPath.Add(windowProfile[i]);
			}
			for (int i = 0; i < num2 + 1; i++)
			{
				bottomWindowPath.Add(windowProfile[i]);
			}
			bottomWindowPath.Reverse();
			for (int i = num2; i < num + 1; i++)
			{
				topWindowPath.Add(windowProfile[i]);
			}
			topWindowPath.Reverse();
		}

		private void DrawRoof(double roofThickness, Transform transform, XYZ ptFrontLeft, XYZ ptFrontMiddle, XYZ ptFrontRight, XYZ ptBackLeft, XYZ ptBackMiddle, XYZ ptBackRight, double eavesOffset, PenColor profileColor)
		{
			XYZ xyz = Geometry.TransformPoint(XYZ.BasisZ, transform) * roofThickness;
			XYZ xyz2 = (ptFrontLeft - ptFrontMiddle).Normalize() * eavesOffset;
			XYZ xyz3 = (ptFrontRight - ptFrontMiddle).Normalize() * eavesOffset;
			XYZ xyz4 = (ptFrontMiddle - ptBackMiddle).Normalize() * eavesOffset;
			double num = ptFrontMiddle.DistanceTo(ptBackMiddle);
			double num2 = ptFrontLeft.DistanceTo(ptBackLeft);
			double num3 = ptFrontLeft.DistanceTo(ptFrontMiddle);
			double num4 = (num - num2) * eavesOffset / num3;
			XYZ xyz5 = (ptFrontMiddle - ptBackMiddle).Normalize() * num4;
			XYZ xyz6 = ptFrontLeft + xyz2 + xyz4;
			XYZ xyz7 = ptFrontRight + xyz3 + xyz4;
			XYZ xyz8 = ptFrontMiddle + xyz4;
			XYZ xyz9 = ptBackLeft + xyz2 + xyz5;
			XYZ xyz10 = ptBackRight + xyz3 + xyz5;
			this.DrawRoofMainSurface(ptFrontLeft, ptFrontMiddle, ptFrontRight, ptBackLeft, ptBackMiddle, ptBackRight, xyz6, xyz8, xyz9, xyz7, xyz10, profileColor, true);
			XYZ ptFrontLeft2 = ptFrontLeft + xyz;
			XYZ ptFrontMiddle2 = ptFrontMiddle + xyz;
			XYZ ptFrontRight2 = ptFrontRight + xyz;
			XYZ ptBackLeft2 = ptBackLeft + xyz;
			XYZ xyz11 = ptBackMiddle + xyz;
			XYZ ptBackRight2 = ptBackRight + xyz;
			XYZ xyz12 = xyz6 + xyz;
			XYZ xyz13 = xyz7 + xyz;
			XYZ xyz14 = xyz8 + xyz;
			XYZ xyz15 = xyz9 + xyz;
			XYZ xyz16 = xyz10 + xyz;
			this.DrawRoofMainSurface(ptFrontLeft2, ptFrontMiddle2, ptFrontRight2, ptBackLeft2, xyz11, ptBackRight2, xyz12, xyz14, xyz15, xyz13, xyz16, profileColor, false);
			this.DrawRoofVerticalSurface(xyz6, xyz8, xyz7, xyz9, ptBackMiddle, xyz10, xyz12, xyz14, xyz13, xyz15, xyz11, xyz16, profileColor);
		}

		private void DrawRoofMainSurface(XYZ ptFrontLeft, XYZ ptFrontMiddle, XYZ ptFrontRight, XYZ ptBackLeft, XYZ ptBackMiddle, XYZ ptBackRight, XYZ ptFrontLeftOffset, XYZ ptFrontMiddleOffset, XYZ ptBackLeftOffset, XYZ ptFrontRightOffset, XYZ ptBackRightOffset, PenColor profileColor, bool isInside)
		{
			List<XYZ> list = new List<XYZ>();
			list.Add(ptFrontLeft);
			list.Add(ptFrontMiddle);
			list.Add(ptBackMiddle);
			list.Add(ptBackLeft);
			if (isInside)
			{
				list.Reverse();
			}
			FillRegion fillRegion = this.CreateFillRegions(list, profileColor);
			if (isInside)
			{
				fillRegion.SetEdgeTransparent(this.ReverseEdgeIndex(list.Count, 0));
				fillRegion.SetEdgeTransparent(this.ReverseEdgeIndex(list.Count, 3));
			}
			else
			{
				fillRegion.SetEdgeTransparent(0);
				fillRegion.SetEdgeTransparent(3);
			}
			this.AddFillRegion(fillRegion);
			List<XYZ> list2 = new List<XYZ>();
			list2.Add(ptFrontLeftOffset);
			list2.Add(ptFrontLeft);
			list2.Add(ptFrontMiddle);
			list2.Add(ptFrontMiddleOffset);
			if (!isInside)
			{
				list2.Reverse();
			}
			FillRegion fillRegion2 = this.CreateFillRegions(list2, profileColor);
			if (!isInside)
			{
				fillRegion2.SetEdgeTransparent(this.ReverseEdgeIndex(list2.Count, 0));
				fillRegion2.SetEdgeTransparent(this.ReverseEdgeIndex(list2.Count, 1));
			}
			else
			{
				fillRegion2.SetEdgeTransparent(0);
				fillRegion2.SetEdgeTransparent(1);
			}
			this.AddFillRegion(fillRegion2);
			List<XYZ> list3 = new List<XYZ>();
			list3.Add(ptFrontLeftOffset);
			list3.Add(ptFrontLeft);
			list3.Add(ptBackLeft);
			list3.Add(ptBackLeftOffset);
			if (isInside)
			{
				list3.Reverse();
			}
			FillRegion fillRegion3 = this.CreateFillRegions(list3, profileColor);
			if (isInside)
			{
				fillRegion3.SetEdgeTransparent(this.ReverseEdgeIndex(list3.Count, 0));
				fillRegion3.SetEdgeTransparent(this.ReverseEdgeIndex(list3.Count, 1));
			}
			else
			{
				fillRegion3.SetEdgeTransparent(0);
				fillRegion3.SetEdgeTransparent(1);
			}
			this.AddFillRegion(fillRegion3);
			List<XYZ> list4 = new List<XYZ>();
			list4.Add(ptFrontRight);
			list4.Add(ptFrontMiddle);
			list4.Add(ptBackMiddle);
			list4.Add(ptBackRight);
			if (!isInside)
			{
				list4.Reverse();
			}
			FillRegion fillRegion4 = this.CreateFillRegions(list4, profileColor);
			if (!isInside)
			{
				fillRegion4.SetEdgeTransparent(this.ReverseEdgeIndex(list4.Count, 0));
				fillRegion4.SetEdgeTransparent(this.ReverseEdgeIndex(list4.Count, 3));
			}
			else
			{
				fillRegion4.SetEdgeTransparent(0);
				fillRegion4.SetEdgeTransparent(3);
			}
			this.AddFillRegion(fillRegion4);
			List<XYZ> list5 = new List<XYZ>();
			list5.Add(ptFrontRightOffset);
			list5.Add(ptFrontRight);
			list5.Add(ptFrontMiddle);
			list5.Add(ptFrontMiddleOffset);
			if (isInside)
			{
				list5.Reverse();
			}
			FillRegion fillRegion5 = this.CreateFillRegions(list5, profileColor);
			if (isInside)
			{
				fillRegion5.SetEdgeTransparent(this.ReverseEdgeIndex(list5.Count, 0));
				fillRegion5.SetEdgeTransparent(this.ReverseEdgeIndex(list5.Count, 1));
			}
			else
			{
				fillRegion5.SetEdgeTransparent(0);
				fillRegion5.SetEdgeTransparent(1);
			}
			this.AddFillRegion(fillRegion5);
			List<XYZ> list6 = new List<XYZ>();
			list6.Add(ptFrontRightOffset);
			list6.Add(ptFrontRight);
			list6.Add(ptBackRight);
			list6.Add(ptBackRightOffset);
			if (!isInside)
			{
				list6.Reverse();
			}
			FillRegion fillRegion6 = this.CreateFillRegions(list6, profileColor);
			if (!isInside)
			{
				fillRegion6.SetEdgeTransparent(this.ReverseEdgeIndex(list6.Count, 0));
				fillRegion6.SetEdgeTransparent(this.ReverseEdgeIndex(list6.Count, 1));
			}
			else
			{
				fillRegion6.SetEdgeTransparent(0);
				fillRegion6.SetEdgeTransparent(1);
			}
			this.AddFillRegion(fillRegion6);
		}

		private void DrawRoofVerticalSurface(XYZ ptFrontLeftOffset, XYZ ptFrontMiddleOffset, XYZ ptFrontRightOffset, XYZ ptBackLeftOffset, XYZ ptBackMiddle, XYZ ptBackRightOffset, XYZ ptFrontLeftOffsetTop, XYZ ptFrontMiddleOffsetTop, XYZ ptFrontRightOffsetTop, XYZ ptBackLeftOffsetTop, XYZ ptBackMiddleTop, XYZ ptBackRightOffsetTop, PenColor profileColor)
		{
			FillRegion fillRegion = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontLeftOffset,
				ptFrontMiddleOffset,
				ptFrontMiddleOffsetTop,
				ptFrontLeftOffsetTop
			}, profileColor);
			fillRegion.SetEdgeTransparent(1);
			this.AddFillRegion(fillRegion);
			FillRegion fillRegion2 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontRightOffset,
				ptFrontRightOffsetTop,
				ptFrontMiddleOffsetTop,
				ptFrontMiddleOffset
			}, profileColor);
			fillRegion2.SetEdgeTransparent(2);
			this.AddFillRegion(fillRegion2);
			FillRegion region = this.CreateFillRegions(new List<XYZ>
			{
				ptBackLeftOffset,
				ptBackLeftOffsetTop,
				ptBackMiddleTop,
				ptBackMiddle
			}, profileColor);
			this.AddFillRegion(region);
			FillRegion region2 = this.CreateFillRegions(new List<XYZ>
			{
				ptBackRightOffset,
				ptBackMiddle,
				ptBackMiddleTop,
				ptBackRightOffsetTop
			}, profileColor);
			this.AddFillRegion(region2);
			FillRegion region3 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontLeftOffset,
				ptFrontLeftOffsetTop,
				ptBackLeftOffsetTop,
				ptBackLeftOffset
			}, profileColor);
			this.AddFillRegion(region3);
			FillRegion region4 = this.CreateFillRegions(new List<XYZ>
			{
				ptFrontRightOffset,
				ptBackRightOffset,
				ptBackRightOffsetTop,
				ptFrontRightOffsetTop
			}, profileColor);
			this.AddFillRegion(region4);
		}

		private void DrawOpening(XYZ ptFrontLeftBottom, XYZ ptFrontRightBottom, XYZ ptFrontLeftTop, XYZ ptFrontRightTop, XYZ ptBackLeftBottom, XYZ ptBackRightBottom, XYZ ptBackLeftTop, XYZ ptBackRightTop, List<XYZ> windowProfile, double wallThickness, Transform transform, PenColor profileColor)
		{
			if (windowProfile.Count == 0)
			{
				FillRegion region = this.CreateFillRegions(new List<XYZ>
				{
					ptFrontLeftTop,
					ptBackLeftTop,
					ptBackRightTop,
					ptFrontRightTop
				}, profileColor);
				this.AddFillRegion(region);
				FillRegion region2 = this.CreateFillRegions(new List<XYZ>
				{
					ptFrontLeftBottom,
					ptFrontRightBottom,
					ptBackRightBottom,
					ptBackLeftBottom
				}, profileColor);
				this.AddFillRegion(region2);
				FillRegion region3 = this.CreateFillRegions(new List<XYZ>
				{
					ptFrontRightBottom,
					ptFrontRightTop,
					ptBackRightTop,
					ptBackRightBottom
				}, profileColor);
				this.AddFillRegion(region3);
				FillRegion region4 = this.CreateFillRegions(new List<XYZ>
				{
					ptFrontLeftBottom,
					ptBackLeftBottom,
					ptBackLeftTop,
					ptFrontLeftTop
				}, profileColor);
				this.AddFillRegion(region4);
				return;
			}
			XYZ xyz = Geometry.TransformPoint(XYZ.BasisY, transform) * wallThickness;
			for (int i = 0; i < windowProfile.Count; i++)
			{
				XYZ xyz2 = windowProfile[i];
				XYZ xyz3;
				if (i == windowProfile.Count - 1)
				{
					xyz3 = windowProfile[0];
				}
				else
				{
					xyz3 = windowProfile[i + 1];
				}
				XYZ item = xyz2 + xyz;
				XYZ item2 = xyz3 + xyz;
				FillRegion fillRegion = this.CreateFillRegions(new List<XYZ>
				{
					xyz2,
					xyz3,
					item2,
					item
				}, profileColor);
				fillRegion.SetEdgeTransparent(0);
				fillRegion.SetEdgeTransparent(1);
				fillRegion.SetEdgeTransparent(2);
				fillRegion.SetEdgeTransparent(3);
				this.AddFillRegion(fillRegion);
			}
		}

		private void DrawWindow(List<List<EdgeInfo>> windowLoops, List<bool> isGlass, double wallThickness, double elevationOffset, Transform transform)
		{
			Transform transform2 = RevitVersionFuncs.CreateTranslation(new XYZ(0.0, wallThickness / 2.0, elevationOffset));
			Transform transform3 = transform.Multiply(transform2);
			int num = 0;
			foreach (List<EdgeInfo> list in windowLoops)
			{
				List<XYZ> list2 = new List<XYZ>();
				int i = 0;
				XYZ xyz = list[i].EndPoint;
				if (!xyz.IsAlmostEqualTo(list[i + 1].StartPoint) && !xyz.IsAlmostEqualTo(list[i + 1].EndPoint))
				{
					xyz = list[i].StartPoint;
				}
				list2.Add(xyz);
				for (i = 1; i < list.Count; i++)
				{
					XYZ xyz2 = list2[list2.Count - 1];
					XYZ xyz3 = list[i].EndPoint;
					if (xyz2.IsAlmostEqualTo(xyz3))
					{
						xyz3 = list[i].StartPoint;
					}
					list2.Add(xyz3);
				}
				List<XYZ> list3 = new List<XYZ>();
				foreach (XYZ xyz4 in list2)
				{
					XYZ xyz5 = new XYZ(Common.FeetToMM(xyz4.X), Common.FeetToMM(xyz4.Y), Common.FeetToMM(xyz4.Z));
					xyz5 = Geometry.TransformPoint(xyz5, transform3);
					list3.Add(xyz5);
				}
				PenColor color = PenColor.PC_Yellow;
				if (isGlass[num])
				{
					color = PenColor.PC_LightBlue;
				}
				FillRegion fillRegion = this.CreateFillRegions(list3, color);
				if (fillRegion.EdgeLoop.Count == 3)
				{
					fillRegion.SetEdgeTransparent(0);
					fillRegion.SetEdgeTransparent(1);
					fillRegion.SetEdgeTransparent(2);
				}
				this.AddFillRegion(fillRegion);
				num++;
			}
		}

		private FillRegion CreateFillRegions(List<XYZ> loop, PenColor color)
		{
			List<EdgeInfo> list = new List<EdgeInfo>();
			for (int i = 0; i < loop.Count; i++)
			{
				XYZ startPoint = loop[i];
				XYZ endPoint;
				if (i == loop.Count - 1)
				{
					endPoint = loop[0];
				}
				else
				{
					endPoint = loop[i + 1];
				}
				EdgeInfo item = new EdgeInfo(startPoint, endPoint, 0.0);
				list.Add(item);
			}
			return new FillRegion(list, color);
		}

		private List<CurveInfo> m_Curves = new List<CurveInfo>();

		private List<TextNoteInfo> m_Texts = new List<TextNoteInfo>();

		private List<FillRegion> m_FillRegions = new List<FillRegion>();

		private Transform m_CurrentTransform;

		private bool m_IsTransparent;

		private bool m_OnlyShowWindow;
	}
}
